<?php
set_time_limit(0);
function writeServerFile($target_file, $xml_data, $mode='wb'){
    $oldMask  = umask(0);
    $fp       = @fopen(CLIENT_CONFIG_DIR."/server/data/harddiskdata.js", $mode);
	$content .="var harddiskData = [];";
    $i=0;
    $len=get_count($xml_data[$i],"id");
	for($j=2;$j<count($xml_data[$i]);$j++){
		if ($xml_data[$i][$j]['id'] != "") {
			$content .= "harddiskData[";
			$content .=$xml_data[$i][$j]['id']."]={";
		    $content .= "id:".$xml_data[$i][$j]['id'].",";
		    $content .= "name:'".$xml_data[$i][$j]['name']."',";
		    $content .= "monsterid:".$xml_data[$i][$j]['monsterid'].",";
		    $content .= "gift:".$xml_data[$i][$j]['gift'];
		    $content .="};";
		}
    }
	$content .="exports.harddiskData = harddiskData;";
	
    fwrite($fp,$content);
    fclose($fp);
    umask($oldMask);
}
?>